package com.xhh.nphm.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhh.nphm.system.domain.AiAnswer;
import com.xhh.nphm.system.domain.AiAnswerLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description: //TODO
 * @author: sun
 * @date: 2023-12-20 13:58
 * @version 1.0
 */
@Mapper
public interface AiAnswerDao extends BaseMapper<AiAnswer> {
    /**
     * 新增操作日志
     * @param aiAnswerLog
     * @return
     */
    @Insert("insert into tm_ai_answer_log(log_time,log_content,log_user_id,log_user_name,log_dept_id,log_dept_name,is_del,use_type) " +
            "values(#{log.logTime},#{log.logContent},#{log.logUserId},#{log.logUserName},#{log.logDeptId},#{log.logDeptName},#{log.isDel},#{log.useType})")
    int addAiAnswerLog(@Param("log") AiAnswerLog aiAnswerLog);

    @Select("select pkId pkId,user_id userId,user_name userName,times times,opt_time optTime,dept_id deptId,dept_name deptName,is_open isOpen,times_all timesAll,times_day timesDay,times_used timesUsed,nums_big numsBig from tm_ai_answer where user_id = #{userId} and is_Open = 0 ")
    AiAnswer selectByUserNo(Long userId);

    @Select("select pkId pkId,user_id userId,user_name userName,times times,opt_time optTime,dept_id deptId,dept_name deptName,is_open isOpen,times_all timesAll,times_day timesDay,times_used timesUsed,nums_big numsBig from tm_ai_answer where is_Open = 0 ")
    List<AiAnswer> selectAllConf();
}
